package com.hzc.springchan.strategy.operationlog;

import com.hzc.springchan.enums.LogOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 操作生成策略环境类
 * @author chen990627
 * @date 2022/10/18
 */
@Service
public class OperationLogContext {

    @Autowired
    private Map<String, IOperationLogStrategy> container;

    public String generateOperation(LogOperation operation, Map<String, Object> paramMap) {

        for (Map.Entry<String, IOperationLogStrategy> entry : container.entrySet()) {
            if (entry.getKey().equals(operation.getOperation())) {
                return entry.getValue().generateInfo(paramMap);
            }
        }
        return null;
    }
}
